<!DOCTYPE html>

<html>
<head>
  <title>symtab.js</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="browser.html">
                browser.js
              </a>
            
              
              <a class="source" href="functions.html">
                functions.js
              </a>
            
              
              <a class="source" href="index.html">
                index.js
              </a>
            
              
              <a class="source" href="parser.html">
                parser.js
              </a>
            
              
              <a class="source" href="symtab.html">
                symtab.js
              </a>
            
              
              <a class="source" href="tokenizer.html">
                tokenizer.js
              </a>
            
              
              <a class="source" href="walker.html">
                walker.js
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>symtab.js</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              
            </div>
            
            <div class="content"><div class='highlight'><pre><span class="comment">/**
 * #Symtable
 * 
 */</span>



<span class="keyword">var</span> Symtable = exports.SymbolTable =  <span class="keyword">function</span>(){

}



<span class="comment">/**
 * ## TODO:
 * 
 * 1. Global
 * 2. Local
 * 3. Struct
 * 4. AtMethod Scope
 */</span>

<span class="keyword">var</span> Scope = exports.Scope = <span class="keyword">function</span>(parentScope){</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <p>this.scopeName = scopeName;</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="keyword">this</span>.parentScope = parentScope;
    <span class="keyword">this</span>.symtable = {};
}

Scope.prototype = {
    getSpace: <span class="keyword">function</span>(){
        <span class="keyword">return</span> <span class="keyword">this</span>.symtable;
    },
    resolve: <span class="keyword">function</span>(name){
        <span class="keyword">var</span> scope = <span class="keyword">this</span>;
        <span class="keyword">while</span>(scope){
            <span class="keyword">var</span> symbol = scope.symtable[name];
            <span class="keyword">if</span>(symbol) <span class="keyword">return</span> symbol;
            <span class="keyword">else</span> scope = scope.parentScope;
        }
    },
    define: <span class="keyword">function</span>(name, value){
        <span class="keyword">this</span>.symtable[name] = value;
        <span class="keyword">return</span> <span class="keyword">this</span>;
    },
    getOuterScope: <span class="keyword">function</span>(){
        <span class="keyword">return</span> <span class="keyword">this</span>.parentScope;
    }
}</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
